import 'package:convex_bottom_bar/convex_bottom_bar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sinosheets/utils/theme/style_utils.dart';

import 'logic.dart';

class BaseTabPage extends StatefulWidget {
  const BaseTabPage({Key? key}) : super(key: key);

  @override
  State<BaseTabPage> createState() => _BaseTabPageState();
}

class _BaseTabPageState extends State<BaseTabPage> {
  final BaseTabLogic logic = Get.put(BaseTabLogic());

  @override
  Widget build(BuildContext context) {
    return GetBuilder<BaseTabLogic>(builder: (get) {
      return Scaffold(
        body: TabBarView(
          controller: get.tabController,
          physics: NeverScrollableScrollPhysics(),
          children: get.bottomBarPages,
        ),
        extendBody: true,
        /*
        bottomNavigationBar: (get.bottomBarPages.length <= get.maxCount)
            ? AnimatedNotchBottomBar(
                notchBottomBarController: get.controller,
                notchColor: ColorUtils.themeColor,
                durationInMilliSeconds: 100,
                bottomBarItems: [
                  BottomBarItem(
                    inActiveItem: Icon(
                      Icons.home_filled,
                      color: Colors.black,
                    ),
                    activeItem: Icon(
                      Icons.home_filled,
                      color: Colors.white,
                    ),
                    itemLabel: 'Home',
                  ),
                  BottomBarItem(
                    inActiveItem: Icon(Icons.grid_view, color: Colors.black),
                    activeItem: Icon(
                      Icons.grid_view,
                      color: Colors.white,
                    ),
                    itemLabel: 'Category',
                  ),
                  BottomBarItem(
                    inActiveItem: Icon(Icons.favorite_border, color: Colors.black),
                    activeItem: Icon(Icons.favorite, color: Colors.white),
                    itemLabel: 'Favorite',
                  ),
                  BottomBarItem(
                    inActiveItem: Icon(Icons.calculate_outlined, color: Colors.black),
                    activeItem: Icon(Icons.calculate_outlined, color: Colors.white),
                    itemLabel: 'Estimate',
                  ),
                  BottomBarItem(
                    inActiveItem: Icon(
                      Icons.settings,
                      color: Colors.black,
                    ),
                    activeItem: Icon(
                      Icons.settings,
                      color: Colors.white,
                    ),
                    itemLabel: 'Settings',
                  )
                ],
                onTap: (index) {
                  get.currentIndex = index;
                  get.controller.jumpTo(index);
                  get.update();
                },
                kIconSize: 24.0,
                kBottomRadius: 28.0)
            : null,
        */
        bottomNavigationBar: ConvexAppBar(
          backgroundColor: Colors.white,
          color: ColorUtils.c_666666,
          activeColor: ColorUtils.themeColor,
          style: TabStyle.react,
          controller: get.tabController,
          items: [
            TabItem(icon: Icons.shopping_bag, title: 'Shopping'),
            TabItem(icon: Icons.branding_watermark, title: 'Trendy Band Says'),
            TabItem(icon: Icons.settings_accessibility, title: 'Settings'),
          ],
          onTap: (index) {
            get.currentIndex = index;
            get.tabController.animateTo(index);
            get.update();
          },
        ),
      );
    });
  }

  @override
  void dispose() {
    Get.delete<BaseTabLogic>();
    super.dispose();
  }
}
